//-----------------------------------------------------------------------------
//	File: task_retenc.c
//	Author: xialing
//		a task for retenc
//-----------------------------------------------------------------------------

#include "task_retenc.h"

// task prio & stk & id
#define TASK_PRIO	90
OS_TID task_retenc_id;

static uint8_t rotval;
static uint8_t keyval;

//-----------------------------------------------------------------------------
//	task_retenc - a task for retenc
//-----------------------------------------------------------------------------
__task void task_retenc(void)
{
	configure_rotenc_gpio();

	while (1) {
		// scan rotenc
		rotval = rotenc_scan();
		keyval = rotenc_key_scan();
		// rotenc
		switch (rotval) {
			case 0x01: // add
				mgui_menu_down();
				break;
			case 0xFF: // sub
				mgui_menu_up();
				break;
		}
		// key
		switch (keyval) {
			case 0x01: // short
				mgui_menu_enter();
				break;
			case 0x02: // long
				break;
		}
		
		os_dly_wait(2);
	}
}

//-----------------------------------------------------------------------------
//	task_retenc_create - task create for retenc
//-----------------------------------------------------------------------------
void task_retenc_create(void)
{
	task_retenc_id = os_tsk_create(task_retenc, TASK_PRIO);
}

